/**
 * 用户组profile
 */
var GroupProfileViewerDialog = (function(){
        
    var groupProfileDialogTmp = [
        '<div class="userProfileViewer">',
            '<div class="userProfileIcon">',
                '<img class="userProfileIconImg" src="<%=o.icon || ujs.getConfigRes("defUserIcon") %>" />',
            '</div>',
            '<div class="userProfileSummary">',
                '<h4 class="userProfileName"><%=o.name%></h4>',
                '<div class="userProfileProperties">',
                    '<div class="userProfilePropertyItem hidden">',
                        '<label class="userProfilePropertyName" lan="lbl.account"></label>',
                        '<label class="userProfilePropertyValue"><%=o.account%></label>',
                    '</div>',
                    '<div class="userProfilePropertyItem">',
                        '<label class="userProfilePropertyName" lan="lbl.desp"></label>',
                        '<label class="userProfilePropertyValue"><%=o.desc || o.desp || o.description%></label>',
                    '</div>',
                    '<div class="userProfilePropertyItem dis" style="display:none">',
                        '<label class="userProfilePropertyName" lan="lbl.distance"></label>',
                        '<label class="userProfilePropertyValue"><%=o.dis%>(km)</label>',
                    '</div>',
                '</div>',
            '</div>',
        '</div>'
    ].join('');
    
    var _UserProfileViewerDialog = function(cfg){
        var _this = this;        
        var perm = this.config['perm'];        
        var buttons = [perm['chat'] ? {
            props : 'chat|Message',                    
            handler : function($btnObj){                      
                page.biz.createChatGroup(
                    Object.toFormData({
                        chat : JSON.stringify({    
                            type : 'adminchat',
                            ugids : [_this.config['group']['id'] ],
                            auids : [].concat(ujs.util.session.getCurrentUserID()),
                            title : _this.config['group']['name'],
                            uids : [].concat(ujs.util.session.getCurrentUserID())
                        })}), 
                    function(msg){                            
                        //add local
                        page.biz.addChatGroupLocal(msg);
                        _this.close();
                        sessionList.startSession(msg['te']['id']);                            
                    }
                );                                    
            }
        } : undefined];
        
        this.setProps({            
            size : {
                width : 500,
                height : 350
            }, 
            //buttons : buttons,
            toolbarStyle : {
                textAlign : 'center'
            }
        });
        
        //添加userProfile表单.
        this.addDialogContent(function($dialogContent) {
            $dialogContent.html(tmpl(groupProfileDialogTmp, _this.config['group']));
            lan.parse($dialogContent);                        
        });
                        
    }.extend(ujs.ui.Dialog);
    
    return _UserProfileViewerDialog;    
})();